package com.anXin.mall.controller;


import com.anXin.mall.service.OrderService;
import com.anXin.model.common.dtos.ResponseResult;
import com.anXin.model.mall.pojos.Order;
import com.anXin.model.mall.vos.OrderVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Resource
    private OrderService orderService;
    @GetMapping("/page/{page}&{pageSize}")
    private ResponseResult<Page<Order>> getPage(@PathVariable int page, @PathVariable int pageSize){
        return  orderService.getOrdersPage(page,pageSize);
    }

    @GetMapping("/list/{userId}")
    private ResponseResult<List<OrderVO>> OrderList(@PathVariable Long userId){
        return orderService.getOrdersList(userId);
    }

    @GetMapping("/getOrder/{id}")
    private ResponseResult<OrderVO> getOrder(Long id){
        return orderService.getOrder(id);
    }

    @PutMapping("/update")
    private ResponseResult<String> updateOrder(Order order){
        return orderService.updataOrder(order);
    }

    @DeleteMapping("delete/{id}")
    private ResponseResult<String> delete(@PathVariable Long id){
        return orderService.deleteOrder(id);
    }


}
